package cn.azzhu.day04.async;

import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.streaming.api.datastream.AsyncDataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.concurrent.TimeUnit;

/**
 * @author azzhu
 * @create 2020-09-19 16:39:21
 */
public class AsyncEsRequest {
    public static void main(String[] args) throws Exception {


        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        DataStreamSource<String> stream = env.socketTextStream("localhost", 8888);

        final SingleOutputStreamOperator<Tuple2<String, String>> result = AsyncDataStream.unorderedWait(stream, new AsyncQueryFromES(), 0, TimeUnit.MILLISECONDS);

        result.print();

        env.execute();

    }
}
